package org.devastra.arcinspect.report;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import org.devastra.arcinspect.analyzer.data.ProjectData;
import org.devastra.arcinspect.core.data.EntityInfo;
import org.devastra.arcinspect.core.data.cache.EntityInfoCache;

public class ArcReporter {

	public void generateHtmlReport(ProjectData _data, String _fileName) {
		Set<String> allNames = EntityInfoCache.getAllEntityInfoName();
		List<String> sortedNames = new ArrayList<String>(allNames);
		Collections.sort(sortedNames);
		
		for(String entityName : sortedNames) {
			EntityInfo eInfo = EntityInfoCache.getEntityInfo(entityName);
			
			switch(eInfo.getType()) {
			case LIBRARY_ELEMENT:
				continue;
			case CLASS:
			case INTERFACE:
			case ENUM:
				reportClass(eInfo);
				
			}
		}
	}
	
	private void reportClass(EntityInfo _entity) {
		System.out.println(_entity.getQualifiedName()+"\t"+_entity.getType());
		for(EntityInfo refEntity : _entity.getReferencedEntityInfo()) {
			System.out.println("\t"+refEntity.getQualifiedName()+"\t"+refEntity.getType());
		}
	}
}
